package com.woniu.controller;

import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniu.entity.FirstTrail;
import com.woniu.entity.LendingOrder;
import com.woniu.service.FirstTrialService;
import com.woniu.service.LendingOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 王汇麒  <br/>
 * Date: 2022/9/28:9:48  <br/>
 * Description:
 */
@Api(value = "待放款列表", tags = {"待放款"})
@RestController
@RequestMapping("/lendingOrder")
public class LendingOrderController extends BaseController {
    @Resource
    private LendingOrderService lendingOrderService;

    @ApiOperation("查询所有订单")
    @GetMapping("/list")
    public TableDataInfo findLendingOrderList(@ApiParam("待放款实体类") LendingOrder lendingOrder){
        startPage();
        List<LendingOrder> lendingOrderList = lendingOrderService.findLendingOrderList(lendingOrder);
        return getDataTable(lendingOrderList);
    }

    @ApiOperation("更新状态")
    @PostMapping("/update")
    public AjaxResult add(@ApiParam("待放款实体类")@Validated @RequestBody LendingOrder lendingOrder){
        return toAjax(lendingOrderService.updateLendingOrder(lendingOrder));
    }

    @ApiOperation("通过id查询")
    @GetMapping("/find/{id}")
    public AjaxResult findFirstTrialById(@PathVariable Integer id){
        LendingOrder lendingOrder = lendingOrderService.findLendingOrderById(id);
        return new AjaxResult(HttpStatus.SUCCESS,"查询成功",lendingOrder);
    }
}
